import config from '@/config'
import {
	getToken
} from '@/utils/auth'

// deepseek官方接口调取
// export default function fetchRequest(url : string, options : any) {
// 	// const deepseekBaseURL = config.deepseekBaseURL
// 	const deepseekKey = config.deepseekKey
// 	const headers = {
// 		"Content-Type": "application/json",
// 		Authorization: `Bearer ${deepseekKey}`,
// 	}
// 	options.headers = {
// 		...headers,
// 		...options.headers,
// 	};
// 	return fetch(deepseekBaseURL + url, options);
// }

// 后端接口使用
export default function fetchRequest(url : string, options : any) {
	const deepseekBaseURL = config.baseUrl

	options.headers = {
		"Content-Type": "application/json",
	}
	if (getToken()) {
		options.headers['Authorization'] = 'Bearer ' + getToken()
	}
	return fetch(deepseekBaseURL + url, options);
}
